package com.czkevin.biliwsclient;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.File;
import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;

public class JSONHelper {

  public static JSONObject loadJson(File file) {
    try (FileInputStream fin = new FileInputStream(file)) {
      return JSON.parseObject(new String(StreamHelper.readFully(fin), StandardCharsets.UTF_8));
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }
  }

}
